/** 
 * 学习目标：综合案例
 * 
 * */
import React from "react";

export default class App extends React.Component {
    state = {
        show: true
    }
    //创建的时候触发
    componentDidMount() {

    }
    render() {

        return (
            <div>
                {this.state.show && <Child></Child>}
            </div>
        )
    }
}
class Child extends React.Component {
    timerId = -1;

    componentDidMount() {
        this.timerId = setInterval(() => { console.log(123); }, 100)
    }

    render() {
        return <div>我是子组件</div>;
    }

    componentWillUnmount() {
        //  清除定时器、解除事件监听
        clearInterval(this.timerId);
    }
}